package com.eims.sls_app.view;

import bls.juejin.cn.R;
import com.eims.sls_app.ui.IdCardActivity;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MyBankDialog extends Dialog implements OnClickListener {

	private Context context;
	private String name, reallyName, cardNum;

	public MyBankDialog(Context context, String name, String reallyName,
			String cardNum) {
		super(context);
		init(context, name, reallyName, cardNum);
		// TODO Auto-generated constructor stub
	}

	public MyBankDialog(Context context, String name, String reallyName,
			String cardNum, boolean cancelable, OnCancelListener cancelListener) {
		super(context, cancelable, cancelListener);
		init(context, name, reallyName, cardNum);
		// TODO Auto-generated constructor stub
	}

	public MyBankDialog(Context context, String name, String reallyName,
			String cardNum, int theme) {
		super(context, theme);
		init(context, name, reallyName, cardNum);
		// TODO Auto-generated constructor stub
	}

	private Button btn_ok, btn_quit;

	private TextView tv_name, tv_reallyName, tv_idCard;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.bang_dialog);
		findView();
		setListener();
	}

	private void init(Context context, String name, String reallyName,
			String cardNum) {
		this.context = context;
		this.name = name;
		this.reallyName = reallyName;
		this.cardNum = cardNum;
	}

	/** 初始化UI */
	private void findView() {
		tv_name = (TextView) this.findViewById(R.id.bank_dialog_name);
		tv_reallyName = (TextView) this
				.findViewById(R.id.bank_dialog_reallyName);
		tv_idCard = (TextView) this.findViewById(R.id.bank_dialog_cardId);
		btn_ok = (Button) this.findViewById(R.id.bank_dialog_btn_ok);
		btn_quit = (Button) this.findViewById(R.id.bank_dialog_btn_quit);

		tv_name.setText("用户名： " + name);
		tv_reallyName.setText("真实姓名： " + reallyName);
		tv_idCard.setText("身份证号： " + cardNum);
	}

	/** 绑定监听 */
	private void setListener() {
		btn_ok.setOnClickListener(this);
		btn_quit.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.bank_dialog_btn_ok:
			showMessage();
			break;
		case R.id.bank_dialog_btn_quit:
			this.dismiss();
			break;
		}
	}

	private void showMessage() {
		IdCardActivity activity = (IdCardActivity) context;
		activity.toNext();
		this.dismiss();
	}

}
